package cn.cocho.android.mc.log;

/**
 * 日志处理类
 * 
 * @author HAIKANG SONG
 * @date 2013-4-17 下午3:07:28
 */
public class LoggerUtils {

	private static String commonTarget = "cn.cocho.android.mc";

	public static LoggerMC log = null;

	/**
	 * 调试信息
	 * 
	 * @param target
	 *            目标类路径
	 * @param msg
	 *            信息
	 * @author HAIKANG SONG
	 * @time 2013-4-22下午5:01:53
	 */
	public static void debug(String target, String msg) {
		if (log != null) {
			log.debug(target, msg);
		}
	}

	/**
	 * 调试信息
	 * 
	 * @param msg
	 * @return void
	 * @author hsx
	 * @time 2013-6-17下午04:12:48
	 */
	public static void debug(String msg) {
		if (log != null) {
			log.debug(commonTarget, msg);
		}
	}

	/**
	 * 提示
	 * 
	 * @param target
	 *            目标类路径
	 * @param msg
	 *            信息
	 * @author HAIKANG SONG
	 * @time 2013-4-22下午5:01:53
	 */
	public static void warn(String target, String msg) {
		if (log != null) {
			log.warn(target, msg);
		}
	}

	/**
	 * 
	 * 提示
	 * 
	 * @param msg
	 * @return void
	 * @author hsx
	 * @time 2013-6-17下午04:13:42
	 */
	public static void warn(String msg) {
		if (log != null) {
			log.warn(commonTarget, msg);
		}
	}

	/**
	 * 异常
	 * 
	 * @param target
	 *            目标类路径
	 * @param msg
	 *            信息
	 * @param e
	 *            异常对象
	 * @author HAIKANG SONG
	 * @time 2013-4-22下午5:02:21
	 */
	public static void error(String target, String msg, Throwable e) {
		if (log != null) {
			log.error(target, msg, e);
		}
	}

	/**
	 * 异常
	 * 
	 * @param target
	 *            目标类路径
	 * @param e
	 *            异常对象
	 * @author HAIKANG SONG
	 * @time 2013-4-22下午5:03:03
	 */
	public static void error(String target, Throwable e) {
		if (log != null) {
			log.error(target, "", e);
		}
	}

	/**
	 * 异常
	 * 
	 * @param e
	 * @return void
	 * @author hsx
	 * @time 2013-6-17下午04:14:30
	 */
	public static void error(Throwable e) {
		if (log != null) {
			log.error(commonTarget, "", e);
		}
	}

	/**
	 * 将异常对象转换为字符串
	 * 
	 * @param e
	 *            异常类对象
	 * @return
	 * @author HAIKANG SONG
	 * @time 2013-4-22下午5:03:31
	 */
	public static String getExcetionMsg(Throwable e) {
		if (log != null) {
			return log.getExcetionMsg(e);
		} else {
			return "";
		}
	}

}
